<!-- Imports -->
<%@page import="java.util.LinkedList"%>
<%@page import="java.util.Iterator"%>
<%@page import="java.util.Hashtable"%>
<%@page import="canss.supports.basic"%>
<%@page import="canss.supports.Makequery_select"%>
<!-- Initiation -->
<%
response.setContentType("text/html; charset=UTF-8");
canss.web.controls.WebDBControl webdbcontrol = null;
webdbcontrol = (webdbcontrol==null)?new canss.web.controls.WebDBControlBean():webdbcontrol;
%>
<!-- Preparing inputs -->
<%
String _cid = basic.IIf((String)request.getParameter("_cid"), "");
String _div = basic.IIf((String)request.getParameter("_div"), "");
String[] cur = null;
int i=0;
%>
<!-- Query Compilation -->
<%
	Makequery_select query = new Makequery_select()
.Select("tblContentDescription.tblCID_cid as cid, dc_description as description, dc_title as title, xmpdm_genre as genre, xmp_rating as agelimit, xmpdm_duration as duration,  cansscontent_thumbnail as thumbnail, location as src, xmpdm_moddate as uploadedtime,  dc_publisher as publisher, canssContentDescription_owner as owner, cansscontentdescription_status as status, oneLineDesc")
.PushFrom("tblContentDescription left outer join tblContent on tblContent.tblCID_cid=tblContentDescription.tblCID_cid join tblEventDescription on cansscontentdescription_status=eventid JOIN tblLocation ON tblContentDescription.tblCID_cid=tblLocation.tblContent_tblCID_cid")
.Limit("0, 1")
.PushWhere(String.format("tblContentDescription.tblCID_cid='%s'", _cid));

Iterator<String[]> iter = null;
Hashtable<String, Integer> hash = null;
try
{
	LinkedList<String[]> res = webdbcontrol.Select(query);
	iter = res.iterator();
	if(iter.hasNext())
	{
		String[] curhashtmp = iter.next();
		hash = new Hashtable<String, Integer>(curhashtmp.length);
		for(i=0; i<curhashtmp.length; i++)
	hash.put(curhashtmp[i], i);
	}
}catch(Exception e)
{
	e.printStackTrace();
}
%>
<%
	if(iter.hasNext())
		cur = iter.next();

	if(cur!=null)
	{
%>
		<!-- Data Start -->
		<%
		out.write(String.format("<a onclick=\" $('%s').hide('slide', function(){});  \"><img src=\"design/img/close.png\" class=\"playbutton\" /></a>", _div));
		out.write("  <dl>");
		out.write("   <dt>");
		
		/*
		// no firefox
		out.write(String.format(
				"<embed src=\"%s\" width=\"320\" height=\"240\" autostart=\"1\" />"
				,cur[hash.get("src")]));
		*/
		/*
		// slow
		out.write(String.format(
				"<object style=\"vertical-align:center;\" data=\"data:application/x-silverlight,\" type=\"application/x-silverlight-2\" width=\"320\" height=\"240\">"+
				" <param name=\"source\" value=\"testplayer/MinoPlayer_Ver1_2.xap\" />"+
				" <param name=\"background\" value=\"black\" />"+
				" <param name=\"initParams\" value=\"VideoSource=%s,AutoPlay=true,EnableScrubbing=true,InitialVolume=1,PreviewImage=%s,LogoImage=http://canss.net/CANSSWebService/design/img/logo_text.png,MarkersTimeView=5\" />"+
				" <param name=\"minRuntimeVersion\" value=\"2.0.31005.0\" />"+
				" <param name=\"autoUpgrade\" value=\"true\" />"+
				" <a href=\"http://go.microsoft.com/fwlink/?LinkID=124807\" style=\"text-decoration: none;\">"+
				"  <img src=\"http://go.microsoft.com/fwlink/?LinkId=108181\" alt=\"Get Microsoft Silverlight\" style=\"border-style: none\"/>"+
				" </a>"+
				"</object>"
				,cur[hash.get("src")],cur[hash.get("thumbnail")]));
		*/
		/*
		out.write(String.format(
				"<div id=\"div_player\"><img width=\"320\" height=\"240\" src=\"http://blackan.canss.net/welcome.png\" onclick=\" $.post('testplayer/content_testview_wmp.jsp', {_src:'%s', _image:'%s'}, function(data){$('#div_player').html(data); }) \" /></div>"
				, cur[hash.get("src")],cur[hash.get("thumbnail")]));
		*/
		String tmp = String.format(
				"<object style=\"vertical-align:center;\" data=\"data:application/x-silverlight,\" type=\"application/x-silverlight-2\" width=\"320\" height=\"240\">"+
				" <param name=\"source\" value=\"testplayer/MinoPlayer_Ver1_2.xap\" />"+
				" <param name=\"background\" value=\"black\" />"+
				" <param name=\"initParams\" value=\"VideoSource=%s,AutoPlay=true,EnableScrubbing=true,InitialVolume=1,PreviewImage=%s,LogoImage=http://canss.net/CANSSWebService/design/img/logo_text.png,MarkersTimeView=5\" />"+
				" <param name=\"minRuntimeVersion\" value=\"2.0.31005.0\" />"+
				" <param name=\"autoUpgrade\" value=\"false\" />"+
				"</object>"
				,cur[hash.get("src")],cur[hash.get("thumbnail")]);
		tmp = tmp.replace("\"", "");
		tmp = tmp.replace("'", "");
		out.write(String.format(
				"<div id=\"div_player\" style=\"border:1px solid;width:320px;height:240px; background:url('%s') no-repeat; \"><img src=\"design/img/t_play.png\" class=\"playbutton\" onclick=' $(\"#div_player\").html(\"%s\"); ' style=\"width:50px; height:50px; position:absolute; left:135px; top:145px\" /></div>"
				, cur[hash.get("thumbnail")], tmp));
		/*  background-image:url('http://blackan.canss.net/welcome.png' <img width=\"120\" height=\"240\" src=\"\"  />
		//nostreaming
		out.write(String.format(
				"<object id=\"player\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" name=\"player\" width=\"320\" height=\"240\">"+
				" <param name=\"movie\" value=\"testplayer/player-viral.swf\" />"+
				" <param name=\"allowfullscreen\" value=\"true\" />"+
				" <param name=\"allowscriptaccess\" value=\"always\" />"+
				" <param name=\"flashvars\" value=\"file=%s&image=%s\" />"+
				" <object type=\"application/x-shockwave-flash\" data=\"testplayer/player-viral.swf\" width=\"328\" height=\"200\">"+
				" <param name=\"movie\" value=\"player-viral.swf\" />"+
				" <param name=\"allowfullscreen\" value=\"true\" />"+
				" <param name=\"allowscriptaccess\" value=\"always\" />"+
				" <param name=\"flashvars\" value=\"file=%s&image=%s\" />"+
				" <p><a href=\"http://get.adobe.com/flashplayer\">Get Flash</a> to see this player.</p>"+
				" </object>"+
				" </object>"
				,cur[hash.get("src")],cur[hash.get("thumbnail")],cur[hash.get("src")],cur[hash.get("thumbnail")]));
		*/
		/*
		//button size, slow
		out.write(String.format(
				"<EMBED "+
				"width=320 height=200 "+
				"type=application/x-silverlight-2 "+
				"data=\"data:application/x-silverlight,\" "+
				"source=\"http://channel9.msdn.com/App_Themes/default/VideoPlayer2009_01_29.xap\" "+
				"initParams=\"m=%s,autostart=true,autohide=true,showembed=true, thumbnail=%s, &#13;&#10;postid=455689\" "+
				"enableHtmlAccess=\"true\" "+
				"onerror=\"onSilverlightError\" "+
				"background=\"#00FFFFFF\" "+
				"autoUpgrade=\"true\" "+
				"minRuntimeVersion=\"2.0.31005.0\" />"
				,cur[hash.get("src")],cur[hash.get("thumbnail")]));
		*/
		
		
		
		out.write("   </dt>");
		
		out.write("   <dd>");
		
		//title
		out.write("    <em>");
		out.write("     <strong>Title</strong>");
		out.write(String.format("     <span>%s</span>", cur[hash.get("title")]));
		out.write("    </em>");
		//publisher
		out.write("   <em>");
		out.write("    <strong>Uploader</strong>");
		if(basic.isNotEmpty(cur[hash.get("publisher")]))
			out.write(String.format("    <span>%s(%s)</span>", cur[hash.get("owner")], cur[hash.get("publisher")]));
		else
			out.write(String.format("    <span>%s</span>", cur[hash.get("owner")]));
		out.write("   </em>");
		//cid
		out.write("    <em>");
		out.write("     <strong>Content ID</strong>");
		out.write(String.format("     <span>%s</span>", cur[hash.get("cid")]));
		out.write("    </em>");
		//description
		out.write("    <em>");
		out.write("     <strong>Description</strong>");
		out.write(String.format("     <span>%s</span>", basic.slicer(cur[hash.get("description")], "<br/>", 20)) );
		out.write("    </em>");
		
		out.write("    <a onclick=\" $('#div_showmore_contdescdetail').toggle('slide'); \">see more details</a>");
		out.write("    <div id=\"div_showmore_contdescdetail\" style=\"display:none; border:1px dashed; \">");
		{
			if(basic.isNotEmpty(cur[hash.get("genre")]))
			{
				//genre
				out.write("   <em>");
				out.write("    <strong>Genre</strong>");
				out.write(String.format("    <span>%s</span>", cur[hash.get("genre")]));
				out.write("   </em>");
			}
			if(basic.isNotEmpty(cur[hash.get("agelimit")]))
			{
				//agelimit
				out.write("   <em>");
				out.write("    <strong>Age Limit</strong>");
				out.write(String.format("    <span>%s</span>", cur[hash.get("agelimit")]));
				out.write("   </em>");
			}
			if(basic.isNotEmpty(cur[hash.get("duration")]) && !cur[hash.get("duration")].equalsIgnoreCase("0"))
			{
				//duration
				out.write("   <em>");
				out.write("    <strong>Duration</strong>");
				out.write(String.format("    <span>%s seconds</span>", cur[hash.get("duration")]));
				out.write("   </em>");
			}
			if(basic.isNotEmpty(cur[hash.get("thumbnail")]))
			{
				//thumbnail
				out.write("   <em>");
				out.write("    <strong>Thumbnail</strong>");
				out.write(String.format("    <span><img src=\"%s\" class=\"thumbnail\" style=\"display:block; \"/>%s</span>", cur[hash.get("thumbnail")], basic.slicer(cur[hash.get("thumbnail")], "<br/>", 35)));
				out.write("   </em>");
			}
			if(basic.isNotEmpty(cur[hash.get("src")]))
			{
				//src
				out.write("   <em>");
				out.write("    <strong>Media Address</strong>");
				out.write(String.format("    <span>%s</span>", basic.slicer(cur[hash.get("src")], "<br/>", 35)));
				out.write("   </em>");
			}
			if(basic.isNotEmpty(cur[hash.get("uploadedtime")]))
			{
				//uploadedtime
				out.write("   <em>");
				out.write("    <strong>Uploaded Date</strong>");
				out.write(String.format("    <span>%s</span>", cur[hash.get("uploadedtime")]));
				out.write("   </em>");
			}
			if(basic.isNotEmpty(cur[hash.get("oneLineDesc")]))
			{
				//oneLineDesc
				out.write("   <em>");
				out.write("    <strong>Status</strong>");
				out.write(String.format("    <span>%s</span>", cur[hash.get("oneLineDesc")]));
				out.write("   </em>");
			}
		}
		out.write("    </div>");

		out.write("   </dd>");
		out.write("  </dl>");
		%>
		<!-- Data End -->
		
		<!-- Logging -->
		<%
			//logging
			{
				canss.webservice.service.PortalIntraWebServiceControl portalctl = null;
				portalctl = (portalctl==null)?new canss.webservice.service.PortalIntraWebServiceControlBean():portalctl;
				portalctl.addNewEvent(
						basic.PORTAL_MODULE_ID, 
						basic.LOG_PORTAL_CONTENTDETAIL_REQUEST, 
						canss.encoder.DBStringEncoder.getServerTime().getTime(), 
						String.format(
								"<log><pid>%s</pid><name>%s</name><sessionkey>%s</sessionkey><type>%s</type><cid>%s</cid></log>", 
								basic.IIf((String)session.getAttribute("_pid"), ""), 
								basic.IIf((String)session.getAttribute("_name"), ""), 
								basic.IIf((String)session.getAttribute("_sessionkey"), ""), 
								basic.IIf((String)session.getAttribute("_loginedas"), ""), 
								_cid
								));
			}
		%>
<%
	}
%>